<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MAIN MENU FOR ADMINISTRATORS</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script  >
        $(document).ready(function (){
            $.ajax({
                url:`http://localhost:10265/wsn/findall`,
                type:'GET',
                success:function (response){
                    var userTable=$('#userTable');
                    userTable.empty();

                    $.each(response,function (index,user)
                    {
                        var row='<tr>'+
                            '<td>' + user.username + '</td>' +
                            '<td>' + user.email + '</td>' +
                            '<td>' + user.membershipCardId + '</td>' +
                            '<td>' + user.membershipCardDuration + '</td>' +
                            '<td>' + user.membershipLevel + '</td>' +
                            '<td>' + user.height + '</td>' +
                            '<td>' + user.weight + '</td>' +
                            '</tr>';
                        userTable.append(row);
                    });
                },
                error:function (xhr,status,error){
                    console.error(error);
                }
            });
        });
    </script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        .box {
            margin: 80px auto;
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
        }

        .box1 {
            width: 1000px;
            height: 50px;
            background-color: #ededed;
            border-style: solid;
            border-width: 1px 1px 0px 1px;
            border-color: black;
        }

        .box1 p {
            display: inline-block;
            font-size: 15px;
            margin: 15px 30px;
        }

        .box1 input {
            display: inline-block;
            position: relative;
            left: 760px;
        }

        .box2 {
            width: 1000px;
            height: 50px;
            border-style: solid;
            border-width: 1px;
            border-color: black;
        }

        .box2 input {
            display: inline-block;
            position: relative;
            left: 60px;
            margin: 10px auto;
            margin-left: 40px;
            font-size: 16px;
        }

        .box3 {
            width: 1000px;
            height: 500px;
            border-style: solid;
            border-width: 0px 1px 1px 1px;
            border-color: black;
        }

        th {

            width: 160px;
            height: 48px;
            background-color: #d0d0d0;
        }

        td {
            width: 160px;
            height: 48px;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="box1">
            <p>WS健身管理系统</p>
            <input type="button" name="close" value="X" onclick="window.close();" />
        </div>
        <div class="box2">
            <a href="Add.html"><input type="button" name="add user" value="添加用户"></a>
            <a href="Change.html"><input type="button" name="change role" value="更改角色"></a>
            <input type="button" name="update membership level" value="更新会员等级">
            <a href="Import.html"><input type="button" name="import user" value="导入用户"></a>
            <a href="Login.html"><input type="button" name="exit" value="退出系统"></a>
        </div>
        <div class="box3">
            <table align="center" border="1" cellspacing="2" id="userTable">
                <tr>
                    <th>User Name</th>
                    <th>Email</th>
                    <th>Membership Card ID</th>
                    <th>Membership Card Duration Time</th>
                    <th>Membership Level</th>
                    <th>Height</th>
                    <th>Weight</th>
                </tr>

            </table>
        </div>
    </div>
</body>

</html>